# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgbase=akonadi
pkgname=(akonadi libakonadi)
pkgver=23.04.1
pkgrel=1
pkgdesc='PIM layer, which provides an asynchronous API to access all kind of PIM data'
arch=(x86_64)
url='https://kontact.kde.org'
license=(LGPL)
makedepends=(extra-cmake-modules postgresql qt5-tools kitemmodels kaccounts-integration doxygen)
source=(https://download.kde.org/stable/release-service/$pkgver/src/$pkgname-$pkgver.tar.xz{,.sig})
sha256sums=('386582462d5721587af6657c6cac25a097b3475ac11afc3d3f79a6df6e780e4e'
            'SKIP')
validpgpkeys=(CA262C6C83DE4D2FB28A332A3A6A4DB839EAA6D7  # Albert Astals Cid <aacid@kde.org>
              F23275E4BF10AFC1DF6914A6DBD2CE893E2D1C87  # Christoph Feck <cfeck@kde.org>
              D81C0CB38EB725EF6691C385BB463350D6EF31EF) # Heiko Becker <heiko.becker@kde.org>

build() {
  cmake -B build -S $pkgname-$pkgver \
    -DBUILD_TESTING=OFF \
    -DBUILD_QCH=ON
  cmake --build build
}

package_libakonadi() {
  pkgdesc='Libraries used by applications based on Akonadi'
  depends=(kitemmodels kaccounts-integration)

  DESTDIR="$pkgdir" cmake --install build
  rm -r "$pkgdir"/usr/bin # Provided by akonadi
}

package_akonadi() {
  depends=(libakonadi mariadb)
  optdepends=('postgresql: PostgreSQL backend')

  DESTDIR="$pkgdir" cmake --install build
  rm -r "$pkgdir"/{etc,usr/{include,lib,share}} # Provided by libakonadi
}
